package org.xbzheng.restful_study.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xbzheng.restful_study.model.Role;
import org.xbzheng.restful_study.service.RoleService;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;


    @RequestMapping("/")
    public String index(HttpServletRequest request){
        return "/admin/role/index";
    }

    @RequestMapping("/create")
    @ResponseBody
    public String create(@RequestBody Role role){
        roleService.save(role);
        return "true";
    }

}
